package app.agent.finder

import app.agent.scatchpad.ScratchPadAgent
import app.agent.systems.SystemsAgent
import app.agent.tests.TestsAgent
import app.comet.Subscriber
import app.server.{ServicesResponse, SystemsResponse, TestsResponse}
import im.mange.jetboot.Html._
import im.mange.jetboot.Renderable

case class FinderAgent(subscriber: Subscriber) extends Renderable {
  private val testsAgent = TestsAgent(subscriber)
  private val systemsAgent = SystemsAgent(subscriber)
  private val holder = div(id = "finderAgent", testsAgent, systemsAgent)

  //TODO: maybe this is services agent now (if we choose to show it at all)
  private val scratchPadAgent = ScratchPadAgent(subscriber)

  def render = holder.render

  def onShowResponse(response: TestsResponse) = testsAgent.onShowResponse(response)
  def onShowResponse(response: SystemsResponse) = systemsAgent.onShowResponse(response)
  def onShowResponse(response: ServicesResponse) = scratchPadAgent.onShowResponse(response)

  def hide = holder.empty
}
